extends Area2D

export var speed:int = 100
var life:int = 100
signal tank_ready(tank)
signal tank_injured(life)
# Called when the node enters the scene tree for the first time.
func _ready():
	$TextureProgress.value = life
	emit_signal("tank_ready",self)

func _process(delta):
	if Input.is_action_pressed("ui_up"):
		position.y -= speed * delta
	elif Input.is_action_pressed("ui_down"):
		position.y += speed * delta
	elif Input.is_action_pressed("ui_left"):
		position.x -= speed * delta
	elif Input.is_action_pressed("ui_right"):
		position.x+= speed * delta


func _on_Tank_area_entered(area):
#	print(area is Saw)
	if area is Saw:
#		print(area.damage)
		$AnimationPlayer.play("hit")
		life -= area.damage
		emit_signal("tank_injured",life)
		$TextureProgress.value = life
		if life<=0:
			get_tree().change_scene("res://scene/Main.tscn")
